jun.BotolDetilWin = Ext.extend(Ext.Window, {
    title: 'Botol Item',
    modez: 1,
    width: 400,
    height: 150,
    layout: 'form',
    modal: true,
    padding: 5,
    closeForm: false,
    initComponent: function() {
        this.items = [
            {
                xtype: 'form',
                frame: false,
                bodyStyle: 'background-color: #E4E4E4; padding: 10px',
                id: 'form-BotolDetil',
                labelWidth: 100,
                labelAlign: 'left',
                layout: 'form',
                ref: 'formz',
                border: false,
                items: [
                    {
                        xtype: 'combo',
                        typeAhead: true,
                        triggerAction: 'all',
                        lazyRender: true,
                        mode: 'local',
                        fieldLabel: 'Jenis Botol',
                        store: jun.rztJenisBotol,
                        valueField: 'jenis_botol_id',
                        displayField: 'jenis_botol_name',
                        forceSelection: true,
                        allowBlank: false,
                        ref: '../jenis_botol_id',
                        anchor: '100%'
                    },
                    {
                        xtype: 'numericfield',
                        fieldLabel: 'Jumlah',
                        hideLabel: false,
                        ref: '../jml',
                        maxLength: 30,
                        anchor: '100%'
                    }
                ]
            }];
        this.fbar = {
            xtype: 'toolbar',
            items: [
                {
                    xtype: 'button',
                    text: 'Simpan',
                    ref: '../btnSaveClose'
                },
                {
                    xtype: 'button',
                    text: 'Batal',
                    ref: '../btnCancel'
                }
            ]
        };
        jun.BotolDetilWin.superclass.initComponent.call(this);
//        this.on('activate', this.onActivate, this);
        this.btnSaveClose.on('click', this.onbtnSaveCloseClick, this);
        this.btnCancel.on('click', this.onbtnCancelclick, this);
//        if (this.modez == 1 || this.modez == 2) {
//            this.btnSave.setVisible(false);
//        } else {
//            this.btnSave.setVisible(true);
//        }
    },
    btnDisabled: function(status) {
//        this.btnSave.setDisabled(status);
        this.btnSaveClose.setDisabled(status);
    },
    saveForm: function()
    {
        var jenis_botol_id = this.jenis_botol_id.getValue();
        var a = jun.rztBotolDetil.findExact("jenis_botol_id", parseInt(jenis_botol_id));
        if (a > -1) {
            Ext.MessageBox.alert("Error", "Item botol sudah dimasukkan.");
            return
        }
        var jenis_botol = jun.getJenisBotol(jenis_botol_id);
        var price = parseFloat(jenis_botol.data.price);
        var jml = this.jml.getValue();
        var total = Math.round(parseFloat(price * jml));
        var c = jun.rztBotolDetil.recordType,
                d = new c({
                    jenis_botol_id: jenis_botol_id,
                    jml: jml,
                    price: price,
                    total: total
                });
        jun.rztBotolDetil.add(d);
        jun.rztBotolDetil.refreshData();
        this.close();
    },
    onbtnSaveCloseClick: function()
    {
        this.closeForm = true;
        this.saveForm(true);
    },
    onbtnSaveclick: function()
    {
        this.closeForm = false;
        this.saveForm(false);
    },
    onbtnCancelclick: function() {
        this.close();
    }

});